﻿using System.Reflection;
using DC2010.Objects.Base;
using DC2010.Objects;
using DC2010.Objects.Data;
using log4net;
using EventInfo = DC2010.Objects.Data.EventInfo;


namespace DC2010.Events
{
    public class EventLogic : BaseObject
    {
        protected ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public EventLogic(EventData ed)
        {
            Info = Root.I.EventSystem.GetInfo(ed.InfoId);
            Gfx = Root.I.EventSystem.GetGfx(ed.GfxId);
            Data = ed;
        }

        public EventInfo Info { get; set; }
        public EventGfx Gfx { get; set; }
        public EventData Data { get; set; }

        public delegate bool DCEventHandler(BaseObject aInvoker, BaseObject aTarget);
        public event DCEventHandler On;

        //public virtual void CalcSuccess(CreatureData aCaster, BaseObject aTarget) { }
        public virtual void Invoke(BaseObject aInvoker, BaseObject aTarget)
        {
            if (On != null)
                On(aInvoker, aTarget);
        }

        public void Init()
        { }

        public override string ToString()
        {
            return ShortName;
        }
    }
}
